<template>
<div class="user">
    <div class="common-seach-wrap">
      <el-form
        size="small"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item :label="$t('store.affiliated_store')">
          <el-select v-model="formInline.storeId" :placeholder="$t('store.please_select')">
            <el-option :label="$t('store.all')" value="0"></el-option>
            <el-option
              v-for="(item, index) in storeList"
              :key="index"
              :label="item.storeName"
              :value="item.storeId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('store.verifier_name')">
          <el-input
            v-model="formInline.search"
            :placeholder="$t('store.enter_verifier_name')"
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('store.start_time')">
          <div class="block">
            <span class="demonstration"></span>
            <el-date-picker
              size="small"
              v-model="formInline.createTime"
              type="daterange"
              value-format="YYYY-MM-DD"
              :range-separator="$t('store.to')"
              :start-placeholder="$t('store.start_date')"
              :end-placeholder="$t('store.end_date')"
            ></el-date-picker>
          </div>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="onSubmit"
            >{{$t('store.search')}}</el-button
          >
        </el-form-item>
      </el-form>
    </div>

    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table
          size="small"
          :data="tableData"
          border
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column prop="storeId" label="ID"></el-table-column>
          <el-table-column prop="storeName" :label="$t('store.verifying_store')">
            <template #default="scope">
              <span class="fb orange">{{scope.row.storeName}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="realName" :label="$t('store.verifier')"></el-table-column>
          <el-table-column prop="orderNo" :label="$t('store.order_number')"></el-table-column>
          <el-table-column
            prop="orderTypeText"
            :label="$t('store.order_type')"
          ></el-table-column>
          <el-table-column prop="createTime" :label="$t('store.verification_time')"></el-table-column>
        </el-table>
      </div>

      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import StoreApi from "@/api/store.js";
export default {
  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*所属门店数据*/
      storeList: [],
      /*一页多少条*/
      pageSize: 20,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*横向表单数据模型*/
      formInline: {
        storeId: "",
        search: "",
        createTime: ""
      },
      timeArr: [],
      /*是否打开添加弹窗*/
      open_add: false,
      /*是否打开编辑弹窗*/
      open_edit: false,
      /*当前编辑的对象*/
      userModel: {}
    };
  },
  created() {
    /*获取列表*/
    this.getTableList();
  },
  methods: {
    changeData() {},
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getTableList();
    },
    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getTableList();
    },
    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = self.formInline;
      if (self.formInline.createTime && self.formInline.createTime.length > 1) {
        Params.startDate = self.formInline.createTime[0];
        Params.endDate = self.formInline.createTime[1];
      } else {
        Params.startDate = "";
        Params.endDate = "";
      }
      Params.pageIndex = self.curPage;
      Params.pageSize = self.pageSize;
      self.loading = true;
      StoreApi.orderList(Params, true).then(res => {
        self.loading = false;
        self.tableData = res.data.list.records;
        self.totalDataNumber = res.data.list.total;
        self.storeList = res.data.storeList;
      }).catch(error => {
        self.loading = false;
      });
    },
    /*搜索查询*/
    onSubmit() {
      this.curPage = 1;
      this.getTableList();
    }
  }
};
</script>

